package org.nicocube.airain.re.proc;

import org.nicocube.airain.domain.client.character.Action;
import org.nicocube.airain.domain.client.character.Difficulty;
import org.nicocube.airain.domain.client.character.GameCharacter;
import org.nicocube.airain.domain.client.character.Possession;
import org.nicocube.airain.domain.client.character.SkillIdentifier;
import org.nicocube.airain.domain.client.character.Possession.Type;
import org.nicocube.airain.domain.client.report.WeaponryActionReport;
import org.nicocube.airain.re.RuleResult;
import org.nicocube.airain.re.utils.Alea;

/**
 * Process a Weapon building action
 * @author nicolas
 * @version 0.1
 */
public class WeaponryProcessor extends ChallengeProcessor {

	public WeaponryProcessor(GameCharacter gc, Action action, Alea alea) {
		super(gc, action, alea);
	}

	@Override
	public RuleResult call() throws Exception {
		WeaponryActionReport wap = new WeaponryActionReport();
		RuleResult result = new RuleResult(wap,getGc());
		int success = getAlea().challenge(Difficulty.Complex,getGc().getSkillExpertise(SkillIdentifier.Weaponry));
		if (success>=0) {
			getGc().addPossession(new Possession(Type.javelin,getAction().getGameDate()));
		}
		wap.setSuccess(success);
		return result ;
	}

}
